package main

import (
	"context"
	"douyin/idl/repository/user"
	"fmt"
	"google.golang.org/grpc"
	"net"
)

type USER struct {
}

func (USER) GetUser(c context.Context, request *user.UserRequest) (*user.UserResponse, error) {
	fmt.Println("调用GetUser微服务GetUser方法")
	u := &user.User{
		Id:              0,
		Name:            "我是User微服务返回的信息",
		FollowCount:     0,
		FollowerCount:   0,
		IsFollow:        false,
		Avatar:          nil,
		BackgroundImage: nil,
		Signature:       nil,
		TotalFavorited:  nil,
		WorkCount:       nil,
		FavoriteCount:   nil,
	}
	return &user.UserResponse{
		StatusCode: 0,
		StatusMsg:  nil,
		User:       u,
	}, nil
}

func UInit() {

	server := grpc.NewServer()

	user.RegisterUserServiceServer(server, &USER{})

	listen, _ := net.Listen("tcp", "127.0.0.1:8081")
	fmt.Println("user微服务服务端启动，监听端口：8081")

	server.Serve(listen)
}
func main() {
	UInit()
}
